package com.smarthealthring.mm.presenter;

import android.util.Log;

import com.smarthealthring.mm.api.ApiRequest;
import com.smarthealthring.mm.base.BasePresenter;
import com.smarthealthring.mm.contract.PersonalContract;
import com.smarthealthring.mm.contract.UnloginContract;
import com.smarthealthring.mm.utils.ErrorHanding;
import com.smarthealthring.mm.utils.ToastUtil;

import java.util.Map;

import io.reactivex.functions.Action;

/**
 * Created by bilibili on 2018/5/26.
 */

public class UnloginPresenter extends BasePresenter<UnloginContract.View> implements UnloginContract.Presenter {

    @Override
    public void unlogin(Map<String, String> params) {
        addSubscribe(ApiRequest.unlogin(params)
                .subscribe(response -> {

                }, throwable -> {
                    mView.unloginFail();
                    ToastUtil.shortShow(ErrorHanding.handleError(throwable));
                }, new Action() {
                    @Override
                    public void run() throws Exception {
                        Log.e("注销完成===","in...");
                        mView.unloginSuccess();
                    }
                }));
    }
}
